package com.zpl.common.util;


import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;

/**
 * @author zhupanlin
 * @version 1.0
 * @description: TODO
 * @date 2024/9/8 20:47
 */
public class ChannelUtil {
    
    private ChannelUtil() {}

    /**
     * 获取 channel 标识
     * @param channel 管道
     * @return
     */
    public static String getChannelId(Channel channel) {
        return channel.id().asLongText();
    }

    /**
     * 获取 Channel
     * @param ctx Channel上下文
     * @return
     */
    public static String getChannel(ChannelHandlerContext ctx) {
        return getChannelId(ctx.channel());
    }
    
}
